package aad.storyboard.model;

import java.util.ArrayList;
/**
 *  represents a graphical layer and contains graphicalobjects and their setters/getters
 */
public class Layer {
	
	private boolean valid;	
	private ArrayList<GraphicalObject> graphicalObjects;
	
	public Layer(){
		valid = true;		
		graphicalObjects=new ArrayList <GraphicalObject>();
	}
	
	public void invalidate() {
		this.valid = false;
	}
	
	public void validate(){
		for(GraphicalObject g : graphicalObjects){
			if (g instanceof Image)
			{
				Image img=(Image)g;
				img.validate();
			}
		}
		
	}

	public boolean isValid() {
		boolean valid = true;
		for(GraphicalObject g : graphicalObjects){
			if (g instanceof Image)
			{
				Image img=(Image)g;			
				valid = valid && img.isValid();
			}
		}
		return valid;
	}

	public ArrayList<GraphicalObject> getGraphicalObjects() {
		
		return graphicalObjects;
	}
	
	public void addGraphicalObject(GraphicalObject i) {
		this.graphicalObjects.add(i);
	}

}
